program SofitSystemServer;

{#ROGEN:SofitSystemLibrary.RODL} // RemObjects SDK: Careful, do not remove!

uses
  uROComInit,
  uROComboService,
  Windows,
  Forms,
  fServerForm in 'fServerForm.pas' {ServerForm},
  SofitSystemService_Impl in 'SofitSystemService_Impl.pas' {SofitSystemService: TDARemoteService},
  fServerDataModule in 'fServerDataModule.pas' {ServerDataModule: TDataModule},
  SofitSystemLibrary_Intf in 'SofitSystemLibrary_Intf.pas',
  SofitSystemLibrary_Invk in 'SofitSystemLibrary_Invk.pas',
  fServerConfig in 'fServerConfig.pas' {fmServerConfig},
  SofitLoginService_Impl in 'SofitLoginService_Impl.pas',
  SofitMessageService_Impl in 'SofitMessageService_Impl.pas' {SofitMessageService: TRORemoteDataModule};

{$R *.res}
{$R RODLFile.res}

var
  HServer: HWND;

begin
  HServer := FindWindow('TServerForm',nil);
  if not (HServer = 0) then
  begin
    ShowWindow(HServer,SW_SHOW);
    Exit;
  end;

  if ROStartService('SofitSystemServer', 'SofitSystemServer') then begin
    ROService.CreateForm(TServerDataModule, ServerDataModule);
    ROService.Run;
    Exit;
  end;

  Application.Initialize;
  Application.CreateForm(TServerDataModule, ServerDataModule);
  Application.CreateForm(TServerForm, ServerForm);
  Application.CreateForm(TfmServerConfig, fmServerConfig);
  Application.Run;
end.
